﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using TrackSystem.Entities.Extensions;

namespace TrackSystem.Entities.Dtos.Channel
{
    public class ChnSerialForCreateDto
    {
        /// <summary>
        /// 通道名称
        /// </summary>
        [Display(Name = "名称")]
        [Required]
        public string? Name { get; set; }

        /// <summary>
        /// 通道描述
        /// </summary>
        [Display(Name = "描述")]
        public string? Description { get; set; }

        /// <summary>
        /// 通道远程IP地址
        /// </summary>
        [Display(Name = "串口号")]
        [Required]
        public string? COMn { get; set; }

        /// <summary>
        /// 远程通道端口地址
        /// </summary>
        [Display(Name = "波特率")]
        [Required]
        public int Baudrate { get; set; }

        /// <summary>
        /// 串口参数
        /// </summary>
        [Display(Name="串口参数")]
        [Required]
        [SerialParams]
        public string? SerialParams { get; set; }

        /// <summary>
        /// 通信协议
        /// </summary>
        [Display(Name = "通信协议")]
        [Required]
        public ProtocolEnum Protocol { get; set; }

        /// <summary>
        /// 在MODBU协议下，是否支持21功能
        /// </summary>
        [Display(Name = "支持同时读写")]
        public bool optSupport21Cmd { get; set; }

        /// <summary>
        /// 在MODBU协议下，是否支持3/4功能分离
        /// </summary>
        [Display(Name = "合并3,4功能")]
        public bool optSplit3_4Cmd { get; set; }

        /// <summary>
        /// 通信周期 ms
        /// </summary>
        [Display(Name = "通信周期")]
        [Range(50, int.MaxValue, ErrorMessage = "通信周期最小值为50ms")]
        [Required]
        public int Interval { get; set; }
    }
}
